package org.grow.yc.controller;

import org.grow.yc.dao.PersonMapper;
import org.grow.yc.entity.Person;
import org.grow.yc.service.AnyTool;
import org.grow.yc.service.SomeTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author: xwg
 * @CreateDate: 2024/8/29
 */

@Controller
@ResponseBody
@RequestMapping("/any")
// @Controller Component Service Repository
public class AnyController {

//    private SomeTool someTool =new SomeTool(); ;
    @Autowired
    private SomeTool someTool ;

    @GetMapping("/test1")
//    @RequestMapping("/test1")
    public String test1(){
//        SomeTool s = new SomeTool();
//        s.show(20);
        someTool.show(3);
        return "1111";
    }
    @Autowired
    private AnyTool anyTool  ;
    @PostMapping("/test2")
    public String test2(){
        anyTool.show();

        return "2222";
    }

    @Autowired
    private PersonMapper personMapper;

    @DeleteMapping("/test3")
    public List<Person> test3(){
        List<Person> people = personMapper.selectSome();

        return people;
    }
    @GetMapping("/test4")
    public String test4(HttpServletRequest request, HttpServletResponse response){
        return  "1111";
    }
}
